<template>
  <router-view />
</template>

<script setup>
import { onMounted } from "vue";
import { useStore } from "vuex";
import { getToken } from "@/utils/auth";

const store = useStore();

// 在应用加载时检查登录状态并获取用户信息
onMounted(() => {
  if (getToken()) {
    // 如果有token，自动获取用户信息
    store.dispatch("GetInfo").catch((error) => {
      console.error("获取用户信息失败:", error);
    });
  }
});
</script>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  font-size: 14px;
  color: #333;
  background-color: #f5f7fa;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  text-decoration: none;
  color: #409eff;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}
</style>
